<template>
    <div id="order">
        <div id="header-title">   
                <h2><span>&lt;</span>订单</h2>
        </div>
        <div id="orderContent">
            <div class="orderImg">
            <img src="../assets/images/Order01.png" />
            <h3>登录后查看外卖订单</h3>
            <router-link to="/login" class="gologin">立即登录</router-link>
        </div>

         <div class="orderList">
          <h3><span>我的订单</span></h3>
        <ul>
           
              <li v-for="item in list">
                <img :src="'http://127.0.0.1:2000/'+item.product_img" alt=""/>
                <div class="name">
                  <h4>{{item.product_title}}</h4>
                  <p>{{item.add_time}}</p>
                    <span>单价：￥<i>{{item.all_price}}</i> 元</span>
                 </div>
                 <h5 class="status">订单已完成</h5>
              </li>
          
        
         </ul>
        
        </div>
     </div>
    </div>
</template>

<script>
//引入jQuery
   import $ from 'jquery';

    export default {
        name: 'order',
        data(){
            return{
               list:[]
            }
        },
        methods:{
            
        },
        computed:{

        },
         mounted(){
           var that=this;
            if(sessionStorage.getItem("user_info")){
			    $(".orderImg").hide();
                var user_id=JSON.parse(sessionStorage.getItem("user_info"))._id;
                var url="http://127.0.0.1:2000/api/orderContent?userid="+user_id;
			    that.$http.get(url).then(function(res){
                    that.list=res.body.result;
                },function(err){
                    console.log(err);
                })
                
		}
		else{
			$(".orderList").hide();
			$(".orderImg").show();
		}

        }
    }
</script>